﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace Corina.Converters.Silverlight
{
    public class KeyToPathGeometryConverter : IValueConverter
    {
        private string defaultPath = "F1M874.094,289.369L854.3,254.63C854.028,254.151 853.515,253.856 852.958,253.856 852.403,253.856 851.89,254.151 851.617,254.63L831.824,289.369C831.555,289.84 831.559,290.416 831.835,290.883 832.111,291.348 832.618,291.634 833.165,291.634L872.752,291.634C873.299,291.634 873.805,291.348 874.081,290.883 874.357,290.416 874.361,289.84 874.094,289.369 M855.653,287.189L850.264,287.189 850.264,282.745 855.653,282.745 855.653,287.189z M855.653,279.41L850.264,279.41 850.264,266.077 855.653,266.077 855.653,279.41z";

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string pathdata = defaultPath;
            if (value!=null&&(Application.Current.Resources.Contains(value)))
            {
                pathdata = Application.Current.Resources[value] as string;
            }
            return new StringToPathGeometryConverter().Convert(pathdata);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
